From: Jonas Dreßler Date: Sat, 27 Feb 2021 10:27:23 +0000 (+0100) Subject: keyboard: Ignore focus rects outside the window X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~616^2^2~134 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=746230f8b68fee9efb314f0acade5f65c626c2b3;p=gnome-shell.git keyboard: Ignore focus rects outside the window Apparently some clients, including gtk don't "clip" the focus rectangle to their window bounds when scrolling the focus outside the window. This makes us shift up windows when the focus actually is no longer visible. This issue needs fixing in GTK, it should probably stop reporting focus changes when the focus moves outside of the visible view. We can still do a little bit better on our side though and "clip" the rectangle to the windows frame rect: If it moves out of the window, we simply stop updating our focus rect. The intersection check introduces a small problem though: Some clients (for example gedit) will give us a cursor rect that has a 0 width or height. This won't play well with graphene_rect_intersect() (GrapheneRects never intersect if they are 0-sized), so we set the size to 1 in case we get a 0-sized rectangle. Part-of: --- diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js index 651a560fa..37b077d12 100644 --- a/js/ui/keyboard.js +++ b/js/ui/keyboard.js @@ -609,12 +609,22 @@ var FocusTracker = class { } _setCurrentRect(rect) { + // Some clients give us 0-sized rects, in that case set size to 1 + if (rect.size.width <= 0) + rect.size.width = 1; + if (rect.size.height <= 0) + rect.size.height = 1; + if (this._currentWindow) { const frameRect = this._currentWindow.get_frame_rect(); const grapheneFrameRect = new Graphene.Rect(); grapheneFrameRect.init(frameRect.x, frameRect.y, frameRect.width, frameRect.height); + const rectInsideFrameRect = grapheneFrameRect.intersection(rect)[0]; + if (!rectInsideFrameRect) + return; + rect.offset(-frameRect.x, -frameRect.y); }